package com.bit.demo3;

class Student{
    public String name;
    private int age;
    private double score;
    public static String classes;//加了静态方法只能直接用类名引用

    //不带参数的构造方法
    public Student(){

    }

    public Student(String name, int age, double score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public static String getClasses() {
        return classes;
    }

    public static void setClasses(String classes) {
        Student.classes = classes;
    }

    public void doClass(){
        System.out.println(this.name + "正在上课" + classes);
    }

    public static void func(){
        System.out.println("这是一个静态方法");
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }
}

public class TestDemo {
    public static void main(String[] args) {
        Student student1 = new Student("bit", 18,34.6);
        student1.setName("外星人");
        System.out.println(student1.getName());
        System.out.println(student1);
        Student student2 = new Student("zs", 23, 23.4);
        System.out.println(student2);
    }

    public void func3 (){

    }
    public static void main6(String[] args) {
        TestDemo testDemo = new TestDemo();
        testDemo.func3();
    }

    public static void main5(String[] args) {
        Student.classes = "104java";
        Student student1 = new Student("bit", 18, 34.6);
        student1.doClass();
        System.out.println(student1.name);
    }

    public static void main4(String[] args) {
        //代表student1不指向任何对象
        Student student1 = null;
        student1.classes = "104java";
        System.out.println(Student.classes);
        Student.func();
    }

    public static void main3(String[] args) {
        Student.classes = "104Java";
        System.out.println(Student.classes);
        Student.func();
    }

    public static void main2(String[] args) {
        Student student1 = new Student("张三", 19, 34.2);
        Student student2 = new Student("李四",19, 34.5);
        //类名来进行访问
        Student.classes = "104java";
        System.out.println(student1);
        System.out.println(student2);
        student1.doClass();
        //就很离谱
        student1.classes = "hhhhhh";
        student1.doClass();
    }

    public static void main1(String[] args) {
        //使用类名Student直接调用
        //System.out.println(Student.classes);
        Student student1 = new Student();
        student1.setName("外星人");
        System.out.println(student1.getName());
    }

}
